package com.tcm.kafka;

import io.protostuff.ProtostuffIOUtil;
import io.protostuff.Schema;
import io.protostuff.runtime.RuntimeSchema;
import org.apache.kafka.common.serialization.Deserializer;

public class CompanyProtostuffDeserializer implements Deserializer<Company> {
    @Override
    public Company deserialize(String topic, byte[] bytes) {
        if(bytes == null) return null;
        Schema schema = RuntimeSchema.getSchema(Company.class);
        Company company = new Company();
        ProtostuffIOUtil.mergeFrom(bytes, company, schema);
        return company;
    }
}
